package com.kaesar.leetcode.LeetCode_201_250;

import com.kaesar.leetcode.ListNode;

public class LeetCode_237 {
    public static void deleteNode(ListNode node) {
        node.val = node.next.val;
        node.next = node.next.next;
    }

    public static void main(String[] args) {
        ListNode head = new ListNode(4);
        head.next = new ListNode(5);
        ListNode node_1 = new ListNode(1);
        head.next.next = node_1;
        head.next.next.next = new ListNode(9);

        System.out.println("before deleteNode");
        ListNode cur = head;
        while (cur != null) {
            System.out.print(cur.val + " ");
            cur = cur.next;
        }
        System.out.println();
        deleteNode(node_1);
        System.out.println("after deleteNode");
        while (head != null) {
            System.out.print(head.val + " ");
            head = head.next;
        }
    }
}
